function daysBetween(sDate1,sDate2){
	var time1 = Date.parse(new Date(sDate1));
	var time2 = Date.parse(new Date(sDate2));
	var nDays = Math.abs(parseInt(time2 - time1)/1000/24/3600);
	return nDays;
};

$(function(){
	var totalDay = daysBetween(new Date($("#handleBegin").text()) , new Date($("#handleEnd").text()));
	var today = daysBetween(new Date($("#handleBegin").text()) , new Date().toLocaleDateString());
	var pg = today / totalDay;
	if (today > totalDay) {
		pg = totalDay / today;
	}	
	pg = Math.round(pg * 100);
	var pgpercent = pg/100;
	
	$("#progressBar").attr("aria-valuenow",pgpercent.toString());
	$("#progressBar").width(299*pg/100);

	var theClass = $("#progressBar").attr("class");
	
	$("#progressBar").removeClass(theClass);
	if (pg < 30) {
		$("#progressBar").addClass("progress-bar progress-bar-danger");
	} else if (pg < 50) {
		$("#progressBar").addClass("progress-bar progress-bar-warning");
	} else if (pg < 80) {
		$("#progressBar").addClass("progress-bar progress-bar-primary");
	} else {
		$("#progressBar").addClass("progress-bar progress-bar-success");
	}	
	
	var rush = $("#rushStatus").text();
	if (rush == "一般"){
		$("#rushStatus").css("color","green");
	} else if (rush == "紧急"){
		$("#rushStatus").css("color","blue");
	} else {
		$("#rushStatus").css("color","red");
	}
	
})